import Vue from "vue";
import XEUtils from "xe-utils";
import { digitUppercase } from "@/utils/index.js"
import { parseTime } from "@/utils/ruoyi.js"



Vue.filter('digitUppercase', function (v) {
  if (!v) return ''
  return digitUppercase(v);
})

Vue.filter('imgurl', function (src) {
  if (!src) return ''
  return process.env.VUE_APP_IMAGE_URL+src;
})


Vue.filter('splitImgSrc', function (value,separator) {
  let imgSrc = [];
  if (!value) return []
  let imgs = value.split(separator || ';');
  for(let i in imgs){
    imgSrc.push(process.env.VUE_APP_IMAGE_URL+imgs[i])
  }
  return imgSrc;
})

Vue.filter('splitImgSrcFirst', function (value,separator) {
  if (!value) return ''
  return process.env.VUE_APP_IMAGE_URL+value.split(separator || ';')[0];
})

Vue.filter('toFixed', function (value,digits) {
  if (!value) return 0
  return XEUtils.toFixed(value,digits);
})

Vue.filter('parseTime', function (time, pattern) {
  if (!time) return time
  return parseTime(time, pattern);
})

